package com.collectplus.express.self;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.collectplus.express.R;
import com.collectplus.express.model.SerachStationBean;

import java.util.ArrayList;

import droid.frame.activity.base.BaseAdapterExt;

/**
 * Created by joker on 2017/10/13.
 * 根据关键字搜索附近驿站适配器
 */
public class SelfSerachStationAdapter extends BaseAdapterExt<SerachStationBean.ResultsBean> {

    public SelfSerachStationAdapter(ArrayList<SerachStationBean.ResultsBean> items, Activity context) {
        super(items, context);
        setEmptyView(R.layout.self_service_point_empty);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (hasEmptyView()) {
            return super.getView(position, convertView, parent);
        }
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.adapter_self_serachstation, parent, false);
            holder = new ViewHolder();
            holder.serachName = (TextView) convertView.findViewById(R.id.serach_name);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        SerachStationBean.ResultsBean item = getItem(position);
        holder.serachName.setText(item.getName());
        return convertView;
    }

    private class ViewHolder {
        TextView serachName;// 搜索显示的名字
    }
}
